package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {

	private double overdraft;

	public CheckingAccount(double amount, double overdraft) {
		super(amount);
		this.overdraft=overdraft;
	}
	
	@Override	
	public double maximumAmountToWithdraw() {
		return this.balance+this.overdraft; 
	}
	
	@Override
	public void withdraw(double amount) {
		if (this.balance > amount) this.balance=this.balance-amount;
		else 
			if (this.overdraft > amount) this.overdraft=this.overdraft-amount;
			else System.out.println("Not enough money on the account "+balance+" You can't use overdraft "+overdraft);
//		this.balance = -1; 
		assert ((this.balance >= 0) | (this.overdraft >= 0));
	}
}
